/**
 * BaseBillApi.java
 * com.aabill.api
 *
 * Function： TODO 
 *
 *   ver     date      		author
 * ──────────────────────────────────
 *   		 2012-8-20 		wangjieming
 *
 * Copyright (c) 2012, TNT All Rights Reserved.
*/

package com.jamin.aabill.api;

import com.jamin.aabill.http.PostParameter;
import com.jamin.aabill.utils.Configuration;


/**
 * ClassName:BaseBillApi
 *
 * @author   wangjieming
 * @version  1.0
 * @since    v1.0
 * @Date	 2012-8-20 上午8:42:00 
 */
public class BaseBillApi {

	
	
	protected static final String Scheme = Configuration.getScheme();
	protected static final String HOST = Scheme + "sharesplit.beck8.com/";					//HOST
	protected static final String METHOD_REGISTER = "users/regist.json";					//注册方法
	protected static final String METHOD_LOGIN = "users/login.json";						//登录方法
	//	private static final String METHOD_USER_DETAIL = "users/view.json";					//用户资料方法
	protected static final String METHOD_CIRCLES = "Circles/index.json";					//圈子列表
	protected static final String METHOD_CREATE_CIRCLES = "Circles/createCircle.json";		//创建Circle
	protected static final String METHOD_EDIT_CIRCLES = "Circles/edit.json";				//修改Circle
	protected static final String METHOD_DELETE_CIRCLES = "Circles/delete.json";			//删除Circle
	protected static final String METHOD_INSERT_MEMBER = "Circlemembers/addMember.json";	//增加成员

	protected static final String TAG = "BillApi============";

	/**
	 * 根据接口业务逻辑处理接口返回数据中实体对象类型(bizobj)
	 */
	public static final int TYPE_JSONOBJECT = 1;
	public static final int TYPE_JSONARRAY = 2;

	
	//-------------------------------登录,注册接口,用户信息
	//---------注册
	/**
	 * 注册接口参数<br>
	 * @param name
	 * @param phoneNum
	 * @param email
	 * @param password
	 * @return
	 */
	protected PostParameter[] getRegisterParameter(String name, String phoneNum , 
			String email , String password){
		PostParameter [] postParameter = new PostParameter[4];
		postParameter [0] = new PostParameter("name" , getString(name));
		postParameter [1] = new PostParameter("phoneNum" , getString(phoneNum));
		postParameter [2] = new PostParameter("email" , getString(email));
		postParameter [3] = new PostParameter("password" , getString(password));
		return postParameter;
	}
	
	//---------登录
	/**
	 * 登录接口<br>
	 * @param name
	 * @param password
	 * @return
	 */
	protected PostParameter[] getLoginParameter(String name, String password ){
		PostParameter [] postParameter = new PostParameter[2];
		postParameter [0] = new PostParameter("email" , getString(name));
		postParameter [1] = new PostParameter("password" , getString(password));
		return postParameter;
	}
	
	
	//-------------------------------圈子列表，创建圈子，
	//-----得到圈子列表
	/**
	 * 得到圈子列表接口<br>
	 * @method getCircleParameter
	 * @return
	 * @throws 
	 * @since v1.0
	 */
	protected PostParameter[] getCircleParameter(){
		PostParameter [] postParameter = new PostParameter[0];
		return postParameter;
	}
	
	
	
	//-----创建圈子
	/**
	 * 创建圈子接口参数<br>
	 * @method getCreateCircleParameter
	 * @param name
	 * @param description
	 * @return
	 * @throws 
	 * @since v1.0
	 */
	protected PostParameter[] getCreateCircleParameter(String name, String description){
		PostParameter [] postParameter = new PostParameter[2];
		postParameter [0] = new PostParameter("name" , name);
		postParameter [1] = new PostParameter("description" , description);
		return postParameter;
	}
	
	
	//-----修改圈子
	/**
	 * 修改圈子接口参数<br>
	 * @method getEditCircleParameter
	 * @param id
	 * @param name
	 * @param description
	 * @param active
	 * @return
	 * @throws 
	 * @since v1.0
	 */
	protected PostParameter[] getEditCircleParameter(String id ,String name, String description , int active){
		PostParameter [] postParameter = new PostParameter[4];
		postParameter [0] = new PostParameter("circleID" , id);
		postParameter [1] = new PostParameter("name" , name);
		postParameter [2] = new PostParameter("description" , description);
		postParameter [3] = new PostParameter("active" , active);
		return postParameter;
	}
	
	
	//------删除Circle
	/**
	 * 删除圈子接口参数<br>
	 * @method getDeleteCircleParameter
	 * @param id
	 * @return
	 * @throws 
	 * @since v1.0
	 */
	protected PostParameter[] getDeleteCircleParameter(String id ){
		PostParameter [] postParameter = new PostParameter[1];
		postParameter [0] = new PostParameter("circleID" , id);
		return postParameter;
	}
	
	//-----增加Circle成员
	/**
	 * 增加圈子成员接口参数<br>
	 * @method getInsertMemberParameter
	 * @param circleMember
	 * @return
	 * @throws 
	 * @since v1.0
	 */
	protected PostParameter[] getInsertMemberParameter(String circleMember ){
		PostParameter [] postParameter = new PostParameter[1];
		postParameter [0] = new PostParameter("circlemember" , circleMember);
		return postParameter;
	}
	
	
	
	
	//-----------------------------------------------非接口
	/**
	 * 当字符串为空时，将字符串转成""
	 * @method getString
	 * @param str
	 * @return
	 * @throws 
	 * @since v1.0
	 */
	protected String getString(String str){
		if(null == str ||"null".equals(str)) return "";
		return str;
	}
	
}

